﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace WCYCReader.Base
{
    public static class WCYCBaseModelEx
    {
        public static void NotifyPropertyChanged<T, TProperty>(this T baseModel, Expression<Func<T, TProperty>> expression) where T : WCYCBaseModel
        {
            MemberExpression body = expression.Body as MemberExpression;
            if (body == null)
            {
                throw new NotImplementedException();
            }
            string name = body.Member.Name;
            baseModel.NotifyPropertyChanged(name);
        }

        public static void NotifyPropertyChanging<T, TProperty>(this T baseModel, Expression<Func<T, TProperty>> expression) where T : WCYCBaseModel
        {
            MemberExpression body = expression.Body as MemberExpression;
            if (body == null)
            {
                throw new NotImplementedException();
            }
            string name = body.Member.Name;
            baseModel.NotifyPropertyChanging(name);
        }
    }
}
